package com.zzl.bonds.ticket.constant.type;

import java.util.Arrays;
import java.util.List;

/**
 * 票据数据来源,
 * 1:开立签收，2：转让签收，3融单留存
 * 4.转单留存，5转单失败，6融单失败
 * 以上枚举值为前面页面展示的值，为了不影响原有逻辑，增加frontDisplay字段用于区分数据来源
 *
 * @author : spp
 * @date : 2022/2/23 15:49
 */
public enum TicketTypeSourceEnum {
    /**
     * 票据来源
     */
    OPEN(1, "开立签收", "开立签收的票", "开立签收"),
    TRANSFER(2, "转让签收", "转让签收的票", "转让签收"),
    TRANSFER_KEEP(3, "转让票拆转留存", "转让签收的票，再次转让后剩下来的票", "转单留存"),
    TRANSFER_FINANCE_KEEP(4, "转让票拆融留存", "转让签收的票，融资后剩下的票", "融单留存"),
    OPEN_TRANSFER_KEEP(5, "开立票拆转留存", "开立签收的票，转让后剩下来的票", "转单留存"),
    OPEN_FINANCE_KEEP(6, "开立拆融留存", "开立签收的票，融资后剩下来的票", "融单留存"),
    OPEN_FINANCE(7, "凭证拆融", "被融资掉的票", "凭证拆融"),
    FINANCE_KEEP(11, "凭证拆融留存", "被融资后剩下来的的票", "凭证拆融"),
    TICKET_APPROVING(8, "审批中", "转单/融单审批中的", "审批中"),
    TRANSFER_FAIL(9, "转单失败", "转单审批未通过的票", "转单失败"),
    FINANCE_FAIL(10, "融单失败", "融单审批未通过的票", "融单失败"),
    ;
    private final Integer code;
    private final String value;
    private final String description;
    /**
     * 用于前端展示数据来源
     */
    private final String frontDisplay;

    public static List<Integer> COUNTER_PARTY_LIST = Arrays.asList(1, 2, 3, 7);


    /**
     * 开立票融资留存下的类型   开立1 5 6---》6
     */
    public static final List<Integer> OPEN_IN_LIST = Arrays.asList(1, 5, 6);

    /**
     * 转让票融资留存下的类型    转让 2 3 4 ---》4
     */
    public static final List<Integer> TRANSFER_IN_LIST = Arrays.asList(2, 3, 4);

    /**
     * 融资留存下的类型    转让 7 11---》7
     */
    public static final List<Integer> FINANCE_IN_LIST = Arrays.asList(7, 11);

    TicketTypeSourceEnum(Integer code, String value, String description, String frontDisplay) {
        this.code = code;
        this.value = value;
        this.description = description;
        this.frontDisplay = frontDisplay;
    }

    public static String getValue(Integer code) {
        for (TicketTypeSourceEnum statusEnum : TicketTypeSourceEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.value;
            }
        }
        return "";
    }
    public static String getFrontDisplay(Integer code) {
        for (TicketTypeSourceEnum statusEnum : TicketTypeSourceEnum.values()) {
            if (statusEnum.code.equals(code)) {
                return statusEnum.frontDisplay;
            }
        }
        return "";
    }

    public Integer getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }

    public String getDescription() {
        return description;
    }

    public String getFrontDisplay() {
        return frontDisplay;
    }
}
